package com.sxj.corejava.code08_常用类.日期类;

import com.sxj.corejava.util.DateConstant;
import com.sxj.corejava.util.DateUtil;

import java.text.ParseException;
import java.util.Date;

/**
 * @author 石小俊
 * @date 2024年04月16日 20:19
 */
public class Test03_日期工具类 {
    public static void main(String[] args) throws ParseException {
        Date date = new Date();
        System.out.println(DateUtil.toString(date));
        System.out.println(DateUtil.toString(date, "yyyy-MM-dd HH:mm:ss"));
        System.out.println(DateUtil.toDate("2024年04月15日 20:19:54"));
        System.out.println(DateUtil.toDate("2024-04-15 20:19:54", "yyyy-MM-dd HH:mm:ss"));
        System.out.println(DateUtil.toString(DateUtil.getYesterday(date)));
        System.out.println(DateUtil.toString(DateUtil.getNextDay(date)));
        Date date2 = DateUtil.toDate("2024年04月10日 21:21:21");
        System.out.println(DateUtil.getDuringDay(date, date2));
        Date date3 = DateUtil.toDate("2024年04月20日 21:21:21");
        System.out.println(DateUtil.getDuringDay(date, date3));
        System.out.println(DateUtil.get(date, DateConstant.YEAR));
        System.out.println(DateUtil.get(date, DateConstant.MONTH));
        System.out.println(DateUtil.get(date, DateConstant.DATE));
        System.out.println(DateUtil.get(date, DateConstant.HOURS));
        System.out.println(DateUtil.get(date, DateConstant.MINUTE));
        System.out.println(DateUtil.get(date, DateConstant.SECOND));
    }
}
